package com.hzlx.operationParameters.controller;

import java.util.List;
import java.io.IOException;

import com.hzlx.ResultDto;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.hzlx.operationParameters.domain.OperationParameters;
import com.hzlx.operationParameters.service.IOperationParametersService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 工序参数Controller
 * 
 * @author ruoyi
 * @date 2025-07-01
 */
@RestController
@RequestMapping("/base")
public class OperationParametersController extends BaseController
{
    @Autowired
    private IOperationParametersService operationParametersService;

    /**
     * 查询工序参数列表
     */
    @RequiresPermissions("base-data-service:parameters:list")
    @GetMapping("/parameters/list")
    public TableDataInfo list(OperationParameters operationParameters)
    {
        startPage();
        List<OperationParameters> list = operationParametersService.selectOperationParametersList(operationParameters);
        return getDataTable(list);
    }

    /**
     * 导出工序参数列表
     */
    @RequiresPermissions("base-data-service:parameters:export")
    @Log(title = "工序参数", businessType = BusinessType.EXPORT)
    @PostMapping("/parameters/export")
    public void export(HttpServletResponse response, OperationParameters operationParameters)
    {
        List<OperationParameters> list = operationParametersService.selectOperationParametersList(operationParameters);
        ExcelUtil<OperationParameters> util = new ExcelUtil<OperationParameters>(OperationParameters.class);
        util.exportExcel(response, list, "工序参数数据");
    }

    /**
     * 获取工序参数详细信息
     */
    @RequiresPermissions("base-data-service:parameters:query")
    @GetMapping(value = "/parameters/{paramId}")
    public AjaxResult getInfo(@PathVariable("paramId") Long paramId)
    {
        return success(operationParametersService.selectOperationParametersByParamId(paramId));
    }

    /**
     * 新增工序参数
     */
    @RequiresPermissions("base-data-service:parameters:add")
    @Log(title = "工序参数", businessType = BusinessType.INSERT)
    @PostMapping("/parameters")
    public AjaxResult add(@RequestBody OperationParameters operationParameters)
    {
        return toAjax(operationParametersService.insertOperationParameters(operationParameters));
    }

    /**
     * 修改工序参数
     */
    @RequiresPermissions("base-data-service:parameters:edit")
    @Log(title = "工序参数", businessType = BusinessType.UPDATE)
    @PutMapping("/parameters")
    public AjaxResult edit(@RequestBody OperationParameters operationParameters)
    {
        return toAjax(operationParametersService.updateOperationParameters(operationParameters));
    }

    /**
     * 删除工序参数
     */
    @RequiresPermissions("base-data-service:parameters:remove")
    @Log(title = "工序参数", businessType = BusinessType.DELETE)
	@DeleteMapping("/parameters/{paramIds}")
    public AjaxResult remove(@PathVariable Long[] paramIds)
    {
        return toAjax(operationParametersService.deleteOperationParametersByParamIds(paramIds));
    }
}
